package com.sen.common.auth.properties;

import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;

import java.util.ArrayList;
import java.util.List;

/**
 * @author esJiang
 */
@Setter
@Getter
@ConfigurationProperties(prefix = "sen.security")
@RefreshScope
public class SecurityProperties {

    private String admin ;

    /**
     * token续签
     */
    private RenewProperties renewProperties = new RenewProperties();
    /**
     * 配置只进行登录认证，不进行url权限认证的api
     * 所有已登录的人都能访问的api
     */
    private String[] ignoreUrls = {};

    public String[] getUrls() {
        List<String> list = new ArrayList<>();
        for (String url : ignoreUrls) {
            list.add(url);
        }
        return list.toArray(new String[list.size()]);
    }

    /** 不做认证的url，直接放行 */
    private String[] permitUrls = {} ;

    public String[] getAllPermitUrls(){
        List<String> list = new ArrayList<>();
        list.add("/czy-system/baseCode/*") ;
        list.add("/czy-rbac/tenant/list") ;
        for (String url : permitUrls) {
            list.add(url);
        }
        return list.toArray(new String[list.size()]);
    }
}
